<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <search ref='search' :config='searchConfig' @getHeight='getHeight' @search='search' />
    <!-- table区域-begin -->
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        v-bind='vexConfig'
        :align='left'
        :border='true'
        :checkbox-config="checkboxConfig"
        :columns='columns'
        :data='dataSource'
        :height='pageHeight-seachHeight-90'
        :loading='loading'
        :resizable='true'
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        :showOverflow='true'
        :toolbar-config='tableToolbar'
        size='mini'
        @checkbox-change='selectChangeEvent'
        @checkbox-all='selectChangeEvent'
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button type="primary" @click="downExportXls('display_repot')">导出</a-button>
          </div>
        </template>
        <template #detail='{ row,rowIndex }'>
          <a @click='handleDetail(row)'>{{ row.clientCode }}</a>
        </template>

        <template #status='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>
        <template #pager>
          <vxe-pager
            :currentPage.sync='ipagination.current'
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :page-size.sync='ipagination.pageSize'
            :pageSizes='ipagination.pageSizeOptions'
            :total='ipagination.total'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
<!--    <sfaVisitSummaryEntity-modal ref="modalForm" @ok="modalFormOk"></sfaVisitSummaryEntity-modal>-->
    <sfa-visit-details-report-modal ref='modalForm'></sfa-visit-details-report-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import SfaVisitDetailsReportModal from './modules/SfaVisitDetailsReportModal'
import { PageListMixin } from '@/mixins/PageListMixin'

export default {
  name: "SfaVisitSummaryList",
  mixins:[PageListMixin],
  components: {
    SfaVisitDetailsReportModal
  },
  data () {
    return {
      description: '拜访明细报表',
      //查询区域
      searchConfig:[
        {
          type: 'input',
          name: 'createName',
          placeholder: '拜访人'
        },
        {
          type: 'date',
          name: 'createDate',
          placeholder: '拜访日期'
        },
        {
          type: 'j-select',
          name: 'visitType',
          placeholder: '拜访类型',
          dictCode:'visit_type',
        },
      ],
      // 表头
      columns: [
        { type: 'checkbox', width: 50, fixed: 'left' },
        {
          title: '经销商编码',
          minWidth:80,
          field: 'clientCode',
          slots: { default: 'detail' }
        },
        {
          title: '经销商名称',
          minWidth:80,
          field: 'clientName'
        },
        {
          title: '提交时间',
          minWidth:80,
          field: 'createTime'
        },
        {
          title: '拜访类型',
          minWidth:80,
          field: 'visitTypeStr'
        },
        {
          title: '人员姓名',
          minWidth:80,
          field: 'createName'
        },
        {
          title: '职位名称',
          minWidth:80,
          field: 'visitPosName'
        },
        {
          title: '所属组织',
          minWidth:80,
          field: 'orgName'
        },
        {
          title: '进店时间',
          minWidth:80,
          field: 'visitInTime'
        },
        {
          title: '进店打卡状态',
          minWidth:80,
          field: 'visitInStatus'
        },
        {
          title: '离店时间',
          minWidth:80,
          field: 'visitOutTime'
        },
        {
          title: '离店打卡状态',
          minWidth:80,
          field: 'visitOutStatus'
        },

      ],
      isorter: {
        permflag: 'visit_info_list'
      },
      url: {
        list: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitInfoController/findPageListDetail",
        exportXlsUrl: window._CONFIG['domianSfaURL'] + "/sfaVisitSummaryService/todoExcel",
        // delete: "/visit/sfaVisitSummaryEntity/delete",
        deleteBatch: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitSummaryController/deleteBatch",
        // importExcelUrl: "visit/sfaVisitSummaryEntity/importExcel",
      },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    handleDetail(record){
      // if (url || this.url.detail) {
      //   const res = await method(url || this.url.detail, params || { id: record.id })
      //   if (res && res.result) {
      //     record = res.result
      //   }
      // }
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = '详情'
      this.$refs.modalForm.disableSubmit = true

    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
